﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Windows.Forms;

namespace Food
{
	public class FoodCategory
	{
		public string Name;
		public List<Food> FoodList;

		public FoodCategory(XmlNode node)
		{
			FoodList = new List<Food>();

			foreach (XmlNode foodNode in node)
			{
				AddFood(foodNode);
			}
		}

		public void AddFood(XmlNode node)
		{
			Food newFood = new Food(node);
			AddFood(newFood);
		}

		public void AddFood(Food food)
		{
			if (GetFoodByName(food.Name) == null)
			{
				FoodList.Add(food);
			}
		}

		public Food GetFoodByName(string name)
		{
			foreach (Food food in FoodList)
			{
				if (food.Name == name)
				{
					return food;
				}
			}

			return null;
		}

		public void FillCombo(ComboBox combo)
		{
			combo.Items.Clear();
			combo.DisplayMember = "Name";

			foreach (Food food in FoodList)
			{
				//combo.Items.Add(food.Name + "     " + food.Price.ToString());
				combo.Items.Add(food);
			}

			
		}
	}
}
